@extends('admin.layout')
@section('title','修改视频')
@section('content')
                <div class="app_content_div" id="app_content_div_301Index">
                    <h3>修改视频</h3>
                    </div>
                    <form action="/adm/video/{{$oVideo->id}}" method="post" enctype="multipart/form-data" class="form-horizontal">
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label"><span style=" color:red;">*</span>标题</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="name" name="name" value="{{$oVideo->name}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="type" class="col-sm-2 control-label"><span style="color:red;">*</span>视频类型</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="radio" name="type" id="video_type1" value="1" @if($oVideo->type==1) checked @endif> 直播
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="type" id="video_type2" value="0" @if($oVideo->type==0) checked @endif> 录播
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="profile" class="col-sm-2 control-label"><span style="color:red;">*</span>视频简介</label>
                            <div class="col-sm-10">
                                <input type="text" name="profile" id="profile" value="{{$oVideo->profile}}">

                            </div>
                        </div>
                        <div class="form-group">
                            <label for="start_at" class="col-sm-2 control-label"><span style="color:red;">*</span>直播开始时间</label>
                            <div class="col-sm-10">
                                <input type="datetime-local" step="1" class="form-control ui_timepicker" id="start_at" name="start_at" value="{{$oVideo->start_at}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="end_at" class="col-sm-2 control-label"><span style="color:red;">*</span>直播结束时间</label>
                            <div class="col-sm-10">
                                <input type="datetime-local" step="1" class="form-control ui_timepicker" id="end_at" name="end_at" value="{{$oVideo->end_at}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="upload_file" class="col-sm-2 control-label"><span style="color:red;">*</span>缩略图</label>
                            <div class="col-sm-10">
                                <div><img src="{{$oVideo->thumb}}" alt="" style="width:200px;height:160px"></div>
                                <input id="thumb" name="thumb" type="file"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="upload_file" class="col-sm-2 control-label"><span style="color:red;">*</span>视频</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" id="website" name="website"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="expertlist" class="col-sm-2 control-label"><span style="color:red;">*</span>关联专家</label>
                            <div class="col-sm-10">
                                <select id="expert">
                                    @foreach($oExpert as $v)
                                        <option value="{{$v->id}}">姓名:{{$v->name}}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" onclick="update()" class="btn btn-default">确定</button>
                            </div>
                        </div>
                    </form>
                    <script>

                        function update() {

                            var start = document.getElementById("start_at");
                            var start_at = start.value.replace("T", " ");
                            var end = document.getElementById("end_at");
                            var end_at = end.value.replace("T", " ");

                            var name = $('#name').val();
                            var type = $("[name='type']:checked").eq(0).val();
                            var profile = $('#profile').val();
                            var expert_id = $('#expert').val();
                            $.ajaxFileUpload({
                                url: '/adm/video/{{$oVideo->id}}',
                                type: 'PUT',
                                fileElementId:['thumb', 'website'] ,
                                dataType: 'json',
                                data: {
                                    'name': name,
                                    'type': type,
                                    'expert_id':expert_id,
                                    'start_at': start_at,
                                    'end_at': end_at,
                                    'profile':profile,
                                    '_token': '{{csrf_token()}}'
                                },
                                success: function (data) {
                                    if (data.success) {
                                        alert(data.msg);
                                        location.href = '/adm/video';
                                    } else {
                                        alert(data.msg);
                                    }
                                }
                            });
                        }
                    </script>
@endsection
